<template>
	<view class="paper-body">
		

	<!-- 菜单 -->
	<paper-menu @closemask="closemask" @click="click"　
	 @openmenu="openmenu"
	 @closemenu="closemenu" :menushow="menushow" :items="menulist"></paper-menu>
	<!-- 纸条列表 -->
	<paper-list :paperlist="paperlist"></paper-list>
	<!-- 上拉刷新 -->
	<view  @click="lodemore()">
		<load-more  :message="loadmore"></load-more>
	</view>
	</view>
</template>
<script>
	
	import paperList from '../../components/paper/paper-list.vue'
	import loadMore from '../../components/common/load-more.vue'
	import nothing from '../../components/common/nothing.vue'
	import paperMenu from '../../components/paper/paper-menu.vue'
	export default{
		components:{
			paperList,
			loadMore,
			paperMenu
		},
		data() {
			return {
				
				loadmore:'上拉加载更多',
				//菜单显示
				menushow:false,
				menulist:[{
					type:'',
					icon:'',
					name:'拉黑',
				},
				{
					type:'',
					icon:'',
					name:'备注',
				}
				],
				paperlist:[
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					}
					,
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					}
				]
			}
		},
		//下拉刷新
		onPullDownRefresh() {
			
			this.pullDownRefresh()
			
		},
		onReachBottom(){
			
			this.loadmore
		},
		//监视导航栏点击
		onNavigationBarButtonTap(e){
			console.log(e.index)
			switch (e.index){
				case 1:
				this.menushow=true
					break;
				case 0:
				//去好友列表
				uni.navigateTo({
					url:"friend"
				})
					break;	
				default:
					break;
			}
		},
		
		methods:{
			click(index){
				console.log(index)
				this.menushow=false
			},
			//关闭遮罩层
			closemask(){
				this.closemenu=false
				console.log("点击了隐藏")
				
			},
			//点击清除
			tapclean(){
				console.log("点击了清除")
				this.closemenu()
			},
			tapadd(){
				console.log("点击了添加")
				this.closemenu()
			},
			//关闭菜单
			closemenu(){
				this.menushow=false
			},
			//打开
			openmenu(){
				this.menushow=true
				
			},
			//关闭菜单
			
			//上拉加载
			lodemore(){
			console.log(this.loadmore)
				if(this.loadmore!="上拉加载更多"){
					return
				}
				//创建一个虚拟对象
				this.loadmore="加载中"
				
				setTimeout(()=> {
					let obj=	{
								name:'我',
								image:'../../static/demo/datapic/19.jpg',
								time:'12:21',
								message:'三百人大战蔡徐坤',
								noread:1
								}
					
					this.paperlist.push(obj);
					this.loadmore="上拉加载更多"
				}, 1000);
				
				
			},
			
			//下拉刷新方法
			pullDownRefresh(){
				
				setTimeout(()=> {
					 let arr=[
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:1
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:0
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:1
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:2
					},
					{
						name:'蔡徐坤',
						image:'../../static/demo/datapic/19.jpg',
						time:'12:21',
						message:'三百人大战蔡徐坤',
						noread:1
					}
					
				]
				//替换
				this.paperlist=arr
				console.log("开始刷新")
				uni.stopPullDownRefresh();
				console.log("刷新结束")
				}, 1000);
			
			}
		}
	}
</script>

<style scoped lang="scss">
.paper-body{
		padding: 0 20upx;
	}
	
	
</style>